<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta charset="utf-8">
<title>教师批量添加</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
</head>
<style>
.importTeacher {
	padding: 0px 15px 20px 15px;
	margin-bottom: 30px;
}

.importTeacher .importTeacher-con {
	height: 60px;
	background-color: rgb(242, 242, 242);
}

.importTeacher .layui-table-view {
	border: none;
}

.importTeacher .importTeacher-con .leftbtn {
	float: left;
	margin-left: 10px;
	margin-top: 10px;
}

.importTeacher .importTeacher-con .rightbtn {
	float: right;
	margin-top: 10px;
	margin-right: 10px;
}

.importTeacher .importTeacher-con .savebtn {
	float: left;
	margin: 10px 0px 0px 20px;
}

.importTeacher .layui-table-body table tbody .layui-table-hover {
	background: #fffdd3 !important;
}

.importTeacher .layui-table-body table tbody .layui-table-click {
	background: #fdef9b !important;
}
.importTeacher .model{
	margin-top: 40px;
}
.importTeacher .model label {
	font-size: 15px;
}
</style>
<body>
	<div class="importTeacher">
		<div class="layui-block importTeacher-con">
			<div class="layui-form-item">
				<button type="button" class="layui-btn leftbtn" id="test4">
					<i class="layui-icon"></i>选择Excel文件
				</button>
				<a href="../templateDownload/教师信息表.xls" type="reset" class="layui-btn layui-btn-primary rightbtn">下载模板</a>
				<button type="button" class="layui-btn savebtn" lay-submit="" lay-filter="demo1" id="saveTeaList">保存</button>
			</div>
		</div>
		<table class="layui-hide" id="teacher"></table>
		<div class="model">
			<script type="text/html" id="toolbarDemo">
				<label>导入失败的数据</label>
			</script>
			<table class="layui-hide" id="teacherData"></table>
		</div>
	</div>
	<script src="../layui/layui.all.js" charset="utf-8"></script>
	<script src="../js/jquery-3.3.1.js"></script>
	<script>
		layui.use([ 'table', 'upload' ], function() {
			var $ = layui.jquery, upload = layui.upload, table = layui.table;

			//指定允许上传的文件类型
			upload.render({ //允许上传的文件后缀
				elem : '#test4',
				url : '../systeachermanagement/getexceltablelist',
				accept : 'file', //普通文件
				exts : 'xls|xlsx|xlsm', //只允许上传压缩文件
				acceptMime : 'xls|xlsx|xlsm',
				done : function(res) {
					if (res.code == 0) {
						table.render({
							elem : '#teacher',
							url : '../systeachermanagement/excelloadtable?op=0',
							title : '教师数据表',
							skin : 'line',
							even : true,
							cols : [ [{
								field : 'realName',
								title : '真实姓名',
								width : 120
							}, {
								field : 'sex',
								title : '性别',
								width : 70
							}, {
								field : 'email',
								title : '邮箱'
							}, {
								field : 'phone',
								title : '联系电话'
							}, {
								field : 'birthday',
								title : '生日'
							}, {
								field : 'entryTime',
								title : '入职时间',
							}, {
								field : 'schoolid',
								title : '学校编号'
							} ] ]
						});
					} else {

					}
				}
			});

			$("#saveTeaList").click(function() {
				var index = layer.load(0, {
					shade: 0.1
				});
				$.ajax({
					type : 'get',
					url : '../systeachermanagement/savetealist',
					datatype : 'json',
					success : function(data) {
						if (data.code == 0) {
							layer.close(index);
							layer.alert(schooltypedate.msg, {icon: 1});
						} else {
							layer.close(index);
							layer.alert("导入失败，表格已替换为失败信息列表！", {icon: 2});
							table.render({
								elem : '#teacher',
								url : '../systeachermanagement/excelloadtable?op=1',
								title : '教师数据表',
								skin : 'line',
								even : true,
								cols : [ [{
									type : 'numbers',
									title : '编号'
								}, {
									field : 'realName',
									title : '真实姓名'
								}, {
									field : 'sex',
									title : '性别'
								}, {
									field : 'email',
									title : '邮箱'
								}, {
									field : 'phone',
									title : '联系电话'
								}, {
									field : 'birthday',
									title : '生日'
								}, {
									field : 'entryTime',
									title : '入职时间',
								}] ]
							});
						}
					},
					error : function() {
					}
				});

			});
		});
	</script>
</body>

</html>